#pragma once

/**
 * @copyright Copyright (c) 2025 
 * CSG Digital Grid Technology (Guangdong) Co., Ltd.
 * @author zhouyan
 * @brief iec101编码类
*/
#include "xtTypes.h"
#include "IEC_def.h"
#include "IEC_asdu.h"
#include "IEC101_def.h"

namespace XIEC101 {
using namespace XIEC;
class CIEC101Encoder {
public:
    CIEC101Encoder() {}
    static xuint8 constLengthFrame(xuint8* dest, xuint8 ctrlField, xuint16 slave_id, const Settings *settings);
    static xuint8 requestLinkStatus(xuint8 *dest, xuint16 slave_id, const Settings *settings);
    static xuint8 resetLink(xuint8 *dest, xuint16 slave_id, const Settings *settings);
    static xuint8 requestPrimaryData(xuint8 *dest, bool fcb, xuint16 slave_id, const Settings *settings);
    static xuint8 requestSecondaryData(xuint8 *dest, bool fcb, xuint16 slave_id, const Settings *settings);
    static xuint8 variableLengthFrame(xuint8* dest, xuint8 ctrlField,
                                      xuint8 typeId, VSQ vsq, xuint8 cot,
                                      CVectInfoObject& infoObjects, xuint16 slave_id,
                                      const Settings *settings);
    static xuint8 variableLengthFrame(xuint8* dest, xuint8 ctrlField,
                                      xuint8 typeId, VSQ vsq, xuint8 cot,
                                      CInfoObject& infoObject, xuint16 slave_id,
                                      const Settings *settings);
    static xuint8 gen(xuint8 *dest, bool fcb, xuint8 qoi, xuint16 slave_id, const Settings *settings);
    static xuint8* asduPtr(xuint8* dest, const Settings *settings);
};
};
